package org.raymond.icloud.common.core.bean;

import cn.hutool.core.date.DatePattern;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class LogBean {
    private Long id;

    private String requestIP;

    private String method;

    private String requestURI;

    private Date clientTime;

    private String headers;

    private String params;

    private String request;

    private String response;

    private int status;

    private Date startTime;

    private Date endTime;

    public String toString(){
        StringBuilder log = new StringBuilder();
        String clientTimeStr = clientTime==null?"":DatePattern.NORM_DATETIME_MS_FORMAT.format(clientTime);
        String startTimeStr = startTime==null?"":DatePattern.NORM_DATETIME_MS_FORMAT.format(startTime);
        String endTimeStr = endTime==null?"":DatePattern.NORM_DATETIME_MS_FORMAT.format(endTime);

        log.append("RequestIP:").append(requestIP).append(",RequestURI:").append(requestURI)
                .append(",Method:").append(method).append(",ClientTime:").append(clientTimeStr)
                .append(",Headers:").append(headers).append(",Params:").append(params)
                .append(",Request:").append(request).append(",Response:").append(response)
                .append(",Status:").append(status)
                .append(",StartTime:").append(startTimeStr).append(",EndTime:").append(endTimeStr)
                ;
        return log.toString();
    }
}
